package com.exchange.Public;

import android.content.Context;
import android.location.Location;
import android.location.LocationManager;

public class g
{
  private LocationManager a;
  private Context b;

  public g(Context paramContext)
  {
    this.b = paramContext;
  }

  public Location a()
  {
    Location localLocation;
    try
    {
      this.a = ((LocationManager)this.b.getSystemService("location"));
      if (h.a(this.b, "android.permission.ACCESS_FINE_LOCATION"))
      {
        localLocation = this.a.getLastKnownLocation("gps");
        if (localLocation != null)
          n.a(ExchangeConstants.LOG_TAG, "get location from gps:" + localLocation.getLatitude() + "," + localLocation.getLongitude());
      }
      else if (h.a(this.b, "android.permission.ACCESS_COARSE_LOCATION"))
      {
        localLocation = this.a.getLastKnownLocation("network");
        if (localLocation != null)
          n.a(ExchangeConstants.LOG_TAG, "get location from network:" + localLocation.getLatitude() + "," + localLocation.getLongitude());
      }
    }
    catch (Exception localException)
    {
      n.b(ExchangeConstants.LOG_TAG, localException.getMessage());
      localLocation = null;
      break label174:
      n.a(ExchangeConstants.LOG_TAG, "Could not get location from GPS or Cell-id, lack ACCESS_COARSE_LOCATION or ACCESS_COARSE_LOCATION permission?");
      localLocation = null;
    }
    label174: return localLocation;
  }
}